; Exercise 1.12: The following pattern of numbers is called Pascal's triangle.
;
;         1          <- i grows (from 1) \
;       1   1                            |
;     1   2   1                          v
;   1   3   3   1 
; 1   4   6   4   1 
;
; ^
; \- j grows (from 1) ->
;
; The numbers at the edge of the triangle are all 1, and each number inside
; the triangle is the sum of the two numbers above it. Write a procedure that
; computes elements of Pascal's triangle by means of a recursive process.
;

(define (pascal i j)
  (cond ((= i j) 1)
        ((= i 1) 1)
        ((= j 1) 1)
        ((or (> j i) (< i 0) (< j 0)) "Invalid parameters")
        (else (+ (pascal (- i 1) (- j 1)) (pascal (- i 1) j)))))

;
; This implementation uses 1-indexing, which means that the top element of the
; triangle is (1, 1), and to get the second element of the fourth line, one
; would use (4, 2).
;

